angular.module('starter.controllers', [])

.controller('DashCtrl', ['$scope', function($scope) {
  // 插件列表
  $scope.directiveLists = [
    {name: 'demo', href: 'demo', desc: '描述'}
  ]
}])

.controller('ChatsCtrl', function($scope, Chats, socket) {
  // With the new view caching in Ionic, Controllers are only called
  // when they are recreated or on app start, instead of every page change.
  // To listen for when this page is active (for example, to refresh data),
  // listen for the $ionicView.enter event:
  //
  //$scope.$on('$ionicView.enter', function(e) {
  //});
  socket.on('send:name', function (data) {
    console.log('send:name', data);
    $scope.name = data.name;
  });

  socket.on('send:time', function (data) {
    console.log('send:time', data);
    $scope.time = data.time;
  });

  $scope.chats = Chats.all();
  $scope.remove = function(chat) {
    Chats.remove(chat);
  };
})

.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
  $scope.chat = Chats.get($stateParams.chatId);
})

.controller('AccountCtrl', function($scope) {
  $scope.settings = {
    enableFriends: true
  };
});
